CREATE PROCEDURE [acms].[Post_GetCurrentVersionsByPostId]
@SiteId INT, @PostId INT
AS
	declare @PostGuid uniqueidentifier
	select @PostGuid = PostGuid from Post_View where Id = @PostId
	
	declare @tmp DateTime
	set @tmp = [acms].[GetPublishDate](@SiteId, getutcdate())

	SELECT a.*, b.ParentPath, b.PublishDate AS SiteVersion
	From acms.Post_View a
		inner join acms.PostPositions b on a.Id = b.PostId and IsNull(a.PublishFrom, '9999/12/31') = IsNull(b.PublishDate, '9999/12/31')
	where a.PostGuid = @PostGuid and (a.PublishTo > @tmp or a.PublishTo is null)

RETURN 0;